package com.whnk.web.controller.system;

import com.whnk.framework.web.base.BaseController;
import com.whnk.system.service.ISysBatchService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/system/batch")
public class SysBatchController extends BaseController  {

    private String prefix = "system/batch";

    @Autowired
    private ISysBatchService batchService;

    @RequiresPermissions("system:batch:view")
    @GetMapping()
    public String menu()  {
        return prefix + "/batch";
    }

    @GetMapping("/getTable")
    @ResponseBody
    public List<String> getAllTableName () {
        return batchService.getAllTableName();
    }

    @GetMapping("/getFiled/{tableName}")
//    @ResponseBody
    public String getAllFiledName (@PathVariable("tableName") String  tableName,ModelMap mmap) {
        List<String> filedList =  batchService.getAllFiledName(tableName);
        mmap.put("fileds",filedList);
        return prefix + "/filed/select";
    }

}
